duration
time.duration
Fields
Functions
as_duration => time.duration[Redefinition of time.period.as_duration]¶[src]
For `duration`, this feature redefined from `period` will just return an equal `duration`
like `duration.this`.
like `duration.this`.
as_string => String[Redefinition of Any.as_string]¶[src]
Returns a compact string representation of this duration using
a short unit name without padding.
The unit is determined by `unit_for_as_string`, preferring the
largest unit whose integer part still contains at least two digits.
The representation is not exact. Fractional parts are omitted.
Example:
a short unit name without padding.
The unit is determined by `unit_for_as_string`, preferring the
largest unit whose integer part still contains at least two digits.
The representation is not exact. Fractional parts are omitted.
Example:
as_string(u time.time_unit) => String¶[src]
Returns a string representation of this duration using
the supplied unit and its short name without padding.
The representation is not exact. Fractional parts are omitted.
Example:
the supplied unit and its short name without padding.
The representation is not exact. Fractional parts are omitted.
Example:
as_string_long => String¶[src]
Returns a string representation of this duration using
a long unit name without padding.
The unit is determined by `unit_for_as_string`, preferring the
largest unit whose integer part still contains at least two digits.
The representation is not exact. Fractional parts are omitted.
Example:
a long unit name without padding.
The unit is determined by `unit_for_as_string`, preferring the
largest unit whose integer part still contains at least two digits.
The representation is not exact. Fractional parts are omitted.
Example:
as_string_long(u time.time_unit) => String¶[src]
Returns a string representation of this duration using
the supplied unit and its long name without padding.
The representation is not exact. Fractional parts are omitted.
Example:
the supplied unit and its long name without padding.
The representation is not exact. Fractional parts are omitted.
Example:
as_string_pad => String¶[src]
Returns a compact string representation of this duration using
a short unit name with left-padded output for alignment.
The unit is determined by `unit_for_as_string`, preferring the
largest unit whose integer part still contains at least two digits.
The representation is not exact. Fractional parts are omitted.
Example:
a short unit name with left-padded output for alignment.
The unit is determined by `unit_for_as_string`, preferring the
largest unit whose integer part still contains at least two digits.
The representation is not exact. Fractional parts are omitted.
Example:
dynamic_apply(R:Any,F:Typed_Function R,f F) => R[Inherited from Any]¶[src]
dynamic_apply -- apply `f.call` to `Any.this`'s dynamic type and value
This can be used to perform operation on values depending on their dynamic
type.
Here is an example that takes a `Sequence Any` that may contain boxed values
of types `i32` and `f64`. We can now write a feature `get_f64` that extracts
these values converted to `f64` and build a function `sum` that sums them up
as follows:
This can be used to perform operation on values depending on their dynamic
type.
Here is an example that takes a `Sequence Any` that may contain boxed values
of types `i32` and `f64`. We can now write a feature `get_f64` that extracts
these values converted to `f64` and build a function `sum` that sums them up
as follows:
dynamic_type => Type[Inherited from Any]¶[src]
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
infix *(n u64) => time.duration[Redefinition of time.period.infix *]¶[src]
this duration multiplied by factor n
infix +(other time.this.duration) => time.this.duration¶[src]
this duration and another one combined
infix -(other time.this.duration) => time.this.duration¶[src]
this duration minus another duration
infix /(other time.duration.this) => u64¶[src]
this duration divided by duration other, rounding down
is_infinity => bool[Redefinition of time.period.is_infinity]¶[src]
is this period infinite, i.e., it never ends?
prefix $ => String[Inherited from Any]¶[src]
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
scale(f f64) => time.duration¶[src]
this duration multiplied by factor f
NYI: HACK: only works for results < ~292.3 years due to usage of `.as_i64`
NYI: HACK: only works for results < ~292.3 years due to usage of `.as_i64`
unit_for_as_string => time.time_unit¶[src]
Determines the unit for compact string representation.
Prefers larger units, but keeps at least two integer digits so
values such as "0h" or "2h" are avoided in favor of "59m" or "120m".
Prefers larger units, but keeps at least two integer digits so
values such as "0h" or "2h" are avoided in favor of "59m" or "120m".
Type Features
type.a(n u64) => time.duration¶[src]
create duration of n years
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
type.as_string => String[Inherited from Type]¶[src]
string representation of this type to be used for debugging.
result has the form "<name>", but this might change in the future
result has the form "<name>", but this might change in the future
type.days(n u64) => time.duration¶[src]
create duration of n days
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
type.dynamic_type => Type[Inherited from Type]¶[src]
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types, so dynamic_type is redefined to just return
Type.type here.
Note: Typechecking is undecidable when 'type' is a type, Mark B. Reinhold, 1989
see: https://dspace.mit.edu/bitstream/handle/1721.1/149366/MIT-LCS-TR-458.pdf?sequence=6
endless hierarchy of types, so dynamic_type is redefined to just return
Type.type here.
Note: Typechecking is undecidable when 'type' is a type, Mark B. Reinhold, 1989
see: https://dspace.mit.edu/bitstream/handle/1721.1/149366/MIT-LCS-TR-458.pdf?sequence=6
type.equality(a property.orderable.this,b property.orderable.this) => bool[Inherited from orderable]¶[src]
equality implements the default equality relation for values of this type.
This relation must be
- reflexive (equality a a),
- symmetric (equality a b = equality b a), and
- transitive ((equality a b && equality b c) : equality a c).
result is true iff 'a' is considered to represent the same abstract value
as 'b'.
This relation must be
- reflexive (equality a a),
- symmetric (equality a b = equality b a), and
- transitive ((equality a b && equality b c) : equality a c).
result is true iff 'a' is considered to represent the same abstract value
as 'b'.
type.h(n u64) => time.duration¶[src]
create duration of n hours
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
type.hash_code(d time.duration.this) => u64[Redefinition of property.hashable.type.hash_code]¶[src]
create hash code from a duration
type.hours(n u64) => time.duration¶[src]
create duration of n hours
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
type.infix :(T:Any) => bool[Inherited from Type]¶[src]
Is this type assignable to a type parameter with constraint `T`?
The result of this is a compile-time constant that can be used to specialize
code for a particular type.
it is most useful in conjunction with preconditions or `if` statements as in
or
The result of this is a compile-time constant that can be used to specialize
code for a particular type.
it is most useful in conjunction with preconditions or `if` statements as in
or
type.lteq(a time.duration,b time.duration) => bool[Redefinition of property.partially_orderable.type.lteq]¶[src]
total order
type.max => time.duration¶[src]
the maximum duration
type.max_duration_days => u64¶[src]
max value for a duration given in days
type.max_duration_hours => u64¶[src]
max value for a duration given in hours
type.max_duration_micros => u64¶[src]
max value for a duration given in microseconds
type.max_duration_millis => u64¶[src]
max value for a duration given in milliseconds
type.max_duration_minutes => u64¶[src]
max value for a duration given in minutes
type.max_duration_nanos => u64¶[src]
max value for a duration given in nanoseconds
type.max_duration_seconds => u64¶[src]
max value for a duration given in seconds
type.max_duration_weeks => u64¶[src]
max value for a duration given in weeks
type.max_duration_years => u64¶[src]
max value for a duration given in years
type.min(n u64) => time.duration¶[src]
create duration of n min
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
type.minutes(n u64) => time.duration¶[src]
create duration of n min
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
type.ms(n u64) => time.duration¶[src]
create duration of n ms
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
type.name => String[Inherited from Type]¶[src]
name of this type, including type parameters, e.g. 'option (list i32)'.
type.ns(n u64) => time.duration¶[src]
create duration of n ns
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
type.prefix $ => String[Inherited from Type]¶[src]
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
NYI: Redefinition allows the type feature to be distinguished from its normal counterpart, see #3913
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
NYI: Redefinition allows the type feature to be distinguished from its normal counterpart, see #3913
type.s(n u64) => time.duration¶[src]
create duration of n seconds
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
type.seconds(n u64) => time.duration¶[src]
create duration of n seconds
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
type.type_value => Type[Inherited from Any]¶[src]
Get a type as a value.
This is a feature with the effect equivalent to Fuzion's `expr.type` call tail.
It is recommended to use `expr.type` and not `expr.type_value`.
`type_value` is here to show how this can be implemented and to illustrate the
difference to `dynamic_type`.
This is a feature with the effect equivalent to Fuzion's `expr.type` call tail.
It is recommended to use `expr.type` and not `expr.type_value`.
`type_value` is here to show how this can be implemented and to illustrate the
difference to `dynamic_type`.
type.weeks(n u64) => time.duration¶[src]
create duration of n weeks
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
type.years(n u64) => time.duration¶[src]
create duration of n years
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
type.zero => time.duration¶[src]
the zero duration, representing a time span of zero
type.µs(n u64) => time.duration¶[src]
create duration of n µs
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
NYI: UNDER_DEVELOPMENT: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
Applicable universe features
These are features in universe, that have an argument with a type constraint that matches this features type and can therefore be used with it.
equals(T:property.equatable,a T,b T) => bool¶[src]
equals -- feature that compares two values using the equality relation
defined in their type
defined in their type
hash(T:property.hashable,a T) => u64¶[src]
hash of a value
infix !=(T:property.equatable,a T,b T) => bool¶[src]
infix = -- infix operation as shorthand for 'equals'
infix <(T:property.orderable,a T,b T) => bool¶[src]
does this come strictly before other?
infix <=(T:property.partially_orderable,a T,b T) => bool¶[src]
infix <= -- infix operation as shorthand for 'lteq'
infix <>(T:property.orderable,a T,b T) => order¶[src]
three-way comparison between this and other.
result is < 0 if this < other
result is > 0 if this > other
result is = 0 if this = other
result is < 0 if this < other
result is > 0 if this > other
result is = 0 if this = other
infix =(T:property.equatable,a T,b T) => bool¶[src]
infix = -- infix operation as shorthand for 'equals'
infix >(T:property.orderable,a T,b T) => bool¶[src]
does this come strictly after other?
infix >=(T:property.orderable,a T,b T) => bool¶[src]
does this come after other?
infix ∈(T:property.equatable,a T,s container.Set T) => bool¶[src]
is `a` contained in `Set` `s`?
This should usually be called using type inference as in
This should usually be called using type inference as in
infix ∉(T:property.equatable,a T,s container.Set T) => bool¶[src]
is `a` not contained in `Set` `s`?
This should usually be called using type inference as in
This should usually be called using type inference as in
infix ≤(T:property.partially_orderable,a T,b T) => bool¶[src]
infix ≤ -- infix operation as shorthand for 'lteq'
infix ≥(T:property.orderable,a T,b T) => bool¶[src]
does this come after other?
infix ⋄(T:property.orderable,a T,b T) => order¶[src]
three-way comparison between this and other.
result is < 0 if this < other
result is > 0 if this > other
result is = 0 if this = other
result is < 0 if this < other
result is > 0 if this > other
result is = 0 if this = other
lteq(T:property.partially_orderable,a T,b T) => bool¶[src]
lteq -- feature that compares two values using the lteq relation
defined in their type
defined in their type
max(T:property.orderable,a T,b T) => T¶[src]
maximum of two values
memoize(MM:container.Mutable_Map T R,T:property.equatable,R:Any,f Unary R T) => Unary R T¶[src]
memoize `f`.
wraps f so that f will only be called once for every unique input.
The term "memoization" was coined by Donald Michie in 1968 and
is derived from the Latin word "memorandum" ("to be remembered"),
usually truncated as "memo" in American English, and thus carries
the meaning of "turning a function into something to be remembered".
https://en.wikipedia.org/wiki/Memoization
example:
wraps f so that f will only be called once for every unique input.
The term "memoization" was coined by Donald Michie in 1968 and
is derived from the Latin word "memorandum" ("to be remembered"),
usually truncated as "memo" in American English, and thus carries
the meaning of "turning a function into something to be remembered".
https://en.wikipedia.org/wiki/Memoization
example:
min(T:property.orderable,a T,b T) => T¶[src]
minimum of two values
0.099dev (GIT hash e2d5298d8107bb5fe79600fdb06a49bc75756344)
This is intended for high precision time specification and measurement, it
uses a time resolution of 1ns.
The maximum value is about 580 years, so this is not intended for use in
calendars that may require time spans exceeding several centuries or millennia,
nor astrological time spans.